﻿namespace Sidvall.Office
{
    public class WorksheetCellFormat : Sidvall.Office.IWorksheetCellFormat
    {
        #region Public Members

        #region Fill

        public object Fill
        {
            get
            {
                return this.InternalWorksheetCellFormat.Fill;
            }
            set
            {
                this.InternalWorksheetCellFormat.Fill = value as Infragistics.Documents.Excel.CellFill;
            }
        }

        #endregion
        #region Font

        private IWorkbookFont _Font;
        public IWorkbookFont Font
        {
            get
            {
                if (_Font == null)
                    _Font = new WorkbookFont(this.InternalWorksheetCellFormat.Font);
                return _Font;
            }
        }

        #endregion
        #region WrapText

        public bool? WrapText
        {
            get
            {
                switch (this.InternalWorksheetCellFormat.WrapText)
                {
                    case Infragistics.Documents.Excel.ExcelDefaultableBoolean.False:
                        return false;
                    case Infragistics.Documents.Excel.ExcelDefaultableBoolean.True:
                        return true;
                    default:
                        return null;
                }
            }
            set
            {
                if (value == true)
                    this.InternalWorksheetCellFormat.WrapText = Infragistics.Documents.Excel.ExcelDefaultableBoolean.True;
                else if (value == false)
                    this.InternalWorksheetCellFormat.WrapText = Infragistics.Documents.Excel.ExcelDefaultableBoolean.False;
                else
                    this.InternalWorksheetCellFormat.WrapText = Infragistics.Documents.Excel.ExcelDefaultableBoolean.Default;
            }
        }

        #endregion

        #region ToString

        public override string ToString()
        {
            return "WorksheetCellFormat - Sidvall.Office.IG";
        }

        #endregion

        #endregion
        #region Private Members

        internal Infragistics.Documents.Excel.IWorksheetCellFormat InternalWorksheetCellFormat { get; set; }

        #endregion
        #region Constructors

        public WorksheetCellFormat(Infragistics.Documents.Excel.IWorksheetCellFormat worksheetCellFormat)
        {
            this.InternalWorksheetCellFormat = worksheetCellFormat;
        }

        #endregion
    }
}
